<template>
    <div>
        <el-button @click="open"
                 size="small"
              type="success"
                   class="registerAdd"
        >编辑</el-button>
    <el-dialog
            title="编辑"
            :visible.sync="dialogVisible"
            width="50%"
            append-to-body
            @close="handleClose"
            :before-close="handleClose">
        <XDForm :config="config" :data="data">
            <template v-slot:registerCheck="slotData">
                <register-check :data="slotData.data"></register-check>
            </template>
        </XDForm>
    </el-dialog>
    </div>
</template>
<script>
    import EleTableComp from "@/components/EleTableComp";
    import {typeJson} from "@/components/EleTableComp/config";
    import registerLook from "./registerLook";
    import registerCheck from "./registerCheck";
    export default {
        props:"data",
        data() {
            return {
                data: {},
                dialogVisible: false,
                config: {
                    table: [
                        {
                            label: '隐患描述',
                            prop: 'content',
                            value: '',
                            addEditType: 'textArea',
                            required: true,
                        },
                        {
                            label: '隐患发现时间',
                            prop: 'discoverDate',
                            value: '',
                            addEditType: 'timePicker',
                            required: true,
                        },
                        {
                            label: '隐患部位',
                            prop: 'part',
                            hidden: true,
                            value: ''
                        },
                        {
                            label: '隐患来源',
                            prop: 'source',
                            addEditType: 'dropDown',
                            list: typeJson.source,
                            value: '',
                            required: true,
                        },
                        {
                            label: '隐患类别',
                            prop: 'category',
                            addEditType: 'cascader',
                            list: {
                                url: '/riskCategory/getTree?',
                                label: 'name',
                                method: 'GET',
                                value: 'id',
                                data: {}
                            },
                            value: '',
                        },
                        {
                            label: '发现人',
                            prop: 'discoverManId',
                            addEditType:"netDropDown",
                            list: {
                                url: '/memberinfo/getList?',
                                label: 'nickName',
                                method: 'POST',
                                value: 'memberId',
                                data: {
                                    mineId:this.$store.state.mineId
                                }
                            },
                            value: '',
                        },
                        {
                            label: '隐患图片',
                            prop: 'riskPhoto',
                            addEditType: 'upload',
                            value: ''
                        },
                        {
                            label: '是否关联检查',
                            prop: 'examId',
                            addEditType: 'relative',
                            list: typeJson.bool,
                            value: ''
                        },
                        {
                            label: '是否关联检查',
                            addEditType: 'slot',
                            slotName: 'registerCheck'
                        }
                    ],
                    insert: {
                        url: '/riskExcludeNew/insert',
                        method: 'POST',
                        data: this.form,
                        mineId: true
                    },
                },
            }
        },
        components: {
            EleTableComp,
            registerLook,
            registerCheck
        },
        methods: {
            handleClose() {
                this.dialogVisible = false
                this.data = {}
            },
            open() {
                this.dialogVisible = true
                this.data = this.$props.data
            }
        },
    }
</script>
<style lang="scss" scoped>
    .registerAdd {
        margin-left: 10px;
    }
</style>